package com.ruoyi.web.controller.http;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Http.InterfaceResult;
import com.ruoyi.system.service.IInterfaceResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * interfaceResultController
 * 
 * @author ruoyi
 * @date 2022-05-10
 */
@RestController
@RequestMapping("/system/result")
public class InterfaceResultController extends BaseController
{
    @Autowired
    private IInterfaceResultService interfaceResultService;

    /**
     * 查询interfaceResult列表
     */
    @PreAuthorize("@ss.hasPermi('system:result:list')")
    @GetMapping("/list")
    public TableDataInfo list(InterfaceResult interfaceResult)
    {
        startPage();
        List<InterfaceResult> list = interfaceResultService.selectInterfaceResultList(interfaceResult);
        SimpleDateFormat bartDateFormat = new SimpleDateFormat("EEEE-MMMM-dd-yyyy");
        return getDataTable(list);
    }

    /**
     * 导出interfaceResult列表
     */
    @PreAuthorize("@ss.hasPermi('system:result:export')")
    @Log(title = "interfaceResult", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(InterfaceResult interfaceResult)
    {
        List<InterfaceResult> list = interfaceResultService.selectInterfaceResultList(interfaceResult);
        ExcelUtil<InterfaceResult> util = new ExcelUtil<InterfaceResult>(InterfaceResult.class);
        return util.exportExcel(list, "result");
    }

    /**
     * 获取interfaceResult详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:result:query')")
    @GetMapping(value = "/{resultId}")
    public AjaxResult getInfo(@PathVariable("resultId") String resultId)
    {
        return AjaxResult.success(interfaceResultService.selectInterfaceResultById(resultId));
    }

    /**
     * 新增interfaceResult
     */
    @PreAuthorize("@ss.hasPermi('system:result:add')")
    @Log(title = "interfaceResult", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InterfaceResult interfaceResult)
    {
        return toAjax(interfaceResultService.insertInterfaceResult(interfaceResult));
    }

    /**
     * 修改interfaceResult
     */
    @PreAuthorize("@ss.hasPermi('system:result:edit')")
    @Log(title = "interfaceResult", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InterfaceResult interfaceResult)
    {
        return toAjax(interfaceResultService.updateInterfaceResult(interfaceResult));
    }

    /**
     * 删除interfaceResult
     */
    @PreAuthorize("@ss.hasPermi('system:result:remove')")
    @Log(title = "interfaceResult", businessType = BusinessType.DELETE)
	@DeleteMapping("/{resultIds}")
    public AjaxResult remove(@PathVariable String[] resultIds)
    {
        return toAjax(interfaceResultService.deleteInterfaceResultByIds(resultIds));
    }
}
